package edu.sdbi.judge.mapper;

import edu.sdbi.judge.domain.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    List<Comment> selectAll();

    void insert(Comment comment);

    void delete();

    Comment selectByid(@Param("id") String id);

    long countCommentsByTypeAndRelation(@Param("type") int type,
                                        @Param("relationId") String relationId);

    List<Comment> getCommentsByTypeAndRelation(@Param("type") int type,
                                               @Param("relationId") String relationId,
                                               @Param("offset") int offset,
                                               @Param("size") int size);

    @Select("SELECT * FROM comment WHERE text = #{text} AND relation_id = #{relationId} ")
    List<Comment> selectByTextAndRelation(@Param("text") String text,
                                          @Param("relationId") String relationId);

    List<Comment> selectByNewsId(String newsId);

    static List<Comment> selectByCommentId(String id) {
        return null;
    }

    int countCommentsByNewsId(String newsId);

}
